import java.util.Random;
import java.util.Scanner;

public class 双色球系统 {
    public static void main(String[] args) {
        int[] arr = new int[7];
        Random r = new Random();
        for (int i = 0; i < arr.length - 1; ) {
            int number = r.nextInt(33) + 1;
            if (!contains(arr, number)) {
                arr[i] = number;
                i++;
            }
        }
        int bluenumber = r.nextInt(16) + 1;
        arr[arr.length - 1] = bluenumber;
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("本期双色球中奖号码已经生成");
        //输入用户购买的号码
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("请您输入您要购买的号码：");
        int[] userarr = userInput();
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("您购买的号码是：");
        for (int i = 0; i < userarr.length - 1; i++) {
            System.out.print(userarr[i] + " ");
        }
        System.out.print(userarr[userarr.length - 1]);
        int redCount = 0;
        int blueCount = 0;
        for (int i = 0; i < userarr.length - 1; i++) {
            if (contains(arr, userarr[i])) {
                redCount++;
            }
        }
        if (arr[arr.length - 1] == userarr[userarr.length - 1]) {
            blueCount++;
        }
        if (blueCount == 1 && redCount == 6) {
            System.out.println("恭喜您，中了一等奖，奖金10000000元");
        } else if (blueCount == 0 && redCount == 6) {
            System.out.println("恭喜您，中了二等奖，奖金500000元");
        } else if (blueCount == 1 && redCount == 5) {
            System.out.println("恭喜您，中了三等奖，奖金3000元");
        } else if (blueCount == 0 && redCount == 5) {
            System.out.println("恭喜您，中了四等奖，奖金100元");
        } else if (blueCount == 1 && redCount == 4) {
            System.out.println("恭喜您，中了五等奖，奖金5元");
        } else if (blueCount == 0 && redCount == 4) {
            System.out.println("恭喜您，中了六等奖，奖金3元");
        } else if (blueCount == 0 && redCount == 3) {
            System.out.println("恭喜您，中了七等奖，奖金1元");
        } else {
            System.out.println("很遗憾，您没有中奖");
        }
    }

    public static boolean contains(int[] arr, int number) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == number) {
                return true;
            }
        }
        return false;
    }

    public static int[] userInput() {
        Scanner sc = new Scanner(System.in);

        int[] arr = new int[7];
        for (int i = 0; i < 6; ) {
            System.out.println("请输入你要购买的第" + (i + 1) + "个红球号码（1-33）：");
            int number = sc.nextInt();
            if (number < 1 || number > 33) {
                System.out.println("你输入的号码不在范围内，请重新输入");
            } else {
                if (!contains(arr, number)) {
                    arr[i] = number;
                    i++;
                } else {
                    System.out.println("你输入的号码重复了，请重新输入");
                }
            }
        }
        System.out.println("请输入你要购买的蓝球号码（1-16）：");
        int blueNumber = sc.nextInt();
        if (blueNumber < 1 || blueNumber > 16) {
            System.out.println("你输入的号码不在范围内，请重新输入");
        } else {
            arr[6] = blueNumber;
        }
        return arr;
    }
}
